import {
	getCategoryList
} from '../../../services/good/fetchCategoryList';
import Toast from 'tdesign-miniprogram/toast/index';
Page({
	data: {
		list: [],
	},
	async init() {
		try {
			const result = await getCategoryList();
			this.setData({
				list: result,
			});
		} catch (error) {
			console.error('err:', error);
		}
	},

	onShow() {
		// this.getTabBar().init();
	},
	onChange() {
		console.log('ssss');
		Toast({
			context: this,
			selector: '#t-toast',
			message: '该功能正在开发中!',
			icon: '',
			duration: 1000,
		});
		// wx.navigateTo({
		// 	url: '/pages/goods/list/index',
		// });
	},
	onLoad() {
		this.init(true);
	},
	scan: function (e) {
		console.log(e);
		let that = this;
		// //app.showError("功能开发中，敬请期待！");

		wx.scanCode({
			success: (res) => {
				// console.log(res.path.split('?')[1]);
				let add = res.path.split('?')[1]
				let arr = add[1]
				console.log(arr);
				//https://dl.lxcx365.com/index.php?m=Goods&a=g_list&m_id=1&mas_id=10&b_id=1&sort=1&type=breakfast

				// if (that.getUrlParam(res.result, "type") == "breakfast") {
				// 	var mId = that.getUrlParam(res.result, "m_id"),
				// 		masId = that.getUrlParam(res.result, "mas_id"),
				// 		bId = that.getUrlParam(res.result, "b_id"),
				// 		sort = that.getUrlParam(res.result, "sort");

				// if(that.data.isOrder){
				//     //有预约订单
				//     wx.navigateTo({
				//         url: '../breakfast/orderList?sort=' + sort + '&isBreakfirst=' + that.data.isBreakfirst,
				//     });
				// }else{
				//     //无预约订单
				//     if(!that.data.isBreakfirst || that.data.Breakfirst.button_sx == 2){
				//         // 未开启现场点餐
				//         app.showError("您还没有预约订单");
				//     }
				//     if(that.data.isBreakfirst && that.data.Breakfirst.button_sx == 1){
				// 已开启现场点餐
				wx.navigateTo({
					url: '/packageA/pages/Shophomepage/index?' + res.path.split('?')[1],
				});
				//     }
				// }

				// } else {
				// 	// res.result = "https://more.octopus.cn/now/order?a=58&p=35&td_channelid=31&uuid=36a15004525b550a16b410060b43e5f&va=1560163672";
				// 	//存入本地存储
				// 	wx.setStorage({
				// 		key: 'zyOder',
				// 		data: res.result
				// 	});

				// 	wx.navigateTo({
				// 		url: '../OutZy/out',
				// 	});
				// }
			}
		});
		// wx.navigateTo({
		//     // url: '../breakfast/index',
		//     // url: '../breakfast/appointment',
		//     // url: '../breakfast/orderList',
		//     url: '../breakfast/index?m_id=1&mas_id=10&b_id=1&sort=2',
		//     // url: '../groupWeek/index',
		//     // url: '../group/index',
		// });
	},
});